package com.chy.controller;

import com.chy.common.R;
import com.chy.entity.Chat;
import com.chy.service.ChatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/chat")
public class chatController {
    @Autowired
    private ChatService chatService;
    @PostMapping("/add")
    public R<String> addChat(@RequestBody Chat chat) {
        return chatService.save(chat) ? R.success() : R.error();
    }

    @PostMapping("/status")
    public R<Chat> getChatStatus(@RequestBody Chat chat) {
        return chatService.getChatStatus(chat);
    }
    @PostMapping("/status2")
    public R<List<Chat>> getChatStatus2(@RequestBody Chat chat) {
        return chatService.getChatStatus2(chat);
    }
}
